# Author : Jay Patel
# 3D Bedford basin bathy
import plotly.graph_objects as go
import pandas as pd
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
fig = go.Figure(data=[go.Surface(z=z_data.values)])
fig.update_layout(title='Bedford Basin Elevation', autosize=True,
width=900, height=900,
margin=dict(l=65, r=50, b=65, t=90))
fig.show()
# cmap=plt.cm.viridis, linewidth=0.2
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
highlightcolor="limegreen", project_z=True))
import plotly.graph_objects as go
import pandas as pd
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
fig = go.Figure(data=[go.Surface(z=z_data.values)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Bedford Basin Elevation', autosize=True,
width=900, height=900,
margin=dict(l=65, r=50, b=65, t=90))
fig.show()
import plotly.graph_objects as go
import numpy as np
import pandas as pd
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
import plotly.graph_objects as go
import pandas as pd
import numpy as np
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Bedford Basin Elevation', autosize=True,
width=900, height=900,
margin=dict(l=65, r=50, b=65, t=90))
fig.update_layout=dict(xaxis=dict(title='Latitude'),
yaxis=dict(title='Longitude'))
fig.show()
import plotly.graph_objects as go
import pandas as pd
import numpy as np
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
# fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
fig = go.Figure(go.Surface(
contours = {
"x": {"show": True, "start": 44.66875, "end": 44.74791667, "size": 0.04, "color":"white"},
"z": {"show": True, "start": -63.69791667, "end": -63.52708333, "size": 0.05}
},
z=z, x=x, y=y))
fig.update_layout(
scene = {
"xaxis": {"nticks": 20},
"zaxis": {"nticks": 8},
'camera_eye': {"x": 0, "y": -1, "z": 0.5},
"aspectratio": {"x": 1, "y": 1, "z": 0.2}
})
fig.show()
import plotly.graph_objects as go
import pandas as pd
import numpy as np
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
highlightcolor="limegreen", project_z=True))
fig.update_layout(title='<b>Bedford Basin Elevation</b>',xaxis_title="Latitude",
yaxis_title="Longitude",autosize=True,
margin=dict(l=65, r=50, b=65, t=90))
fig.update_layout(scene = dict(
xaxis_title='Latitude',
yaxis_title='Longitude',
zaxis_title='Elevation')
)
# fig.update_layout(color='Elevation')
fig.update_layout(coloraxis_colorbar=dict(
title="Elevation",
thicknessmode="pixels", thickness=50,
lenmode="pixels", len=200,
yanchor="top", y=1,
ticks="outside", ticksuffix="",
dtick=5
))
fig.show()
import plotly.graph_objects as go
import pandas as pd
import numpy as np
# Read data from a csv
z_data = pd.read_csv('bathy_bedford.csv')
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(44.66875, 44.74791667, sh_0), np.linspace(-63.69791667, -63.52708333, sh_1)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y,colorscale='Viridis')])
"""The 'colorscale' property is a colorscale and may be
specified as:
- A list of colors that will be spaced evenly to create the colorscale.
Many predefined colorscale lists are included in the sequential, diverging,
and cyclical modules in the plotly.colors package.
- A list of 2-element lists where the first element is the
normalized color level value (starting at 0 and ending at 1),
and the second item is a valid color string.
(e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])
- One of the following named colorscales:
['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',
'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',
'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',
'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',
'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',
'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',
'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',
'orrd', 'oryel', 'peach', 'phase', 'picnic', 'pinkyl', 'piyg',
'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn', 'puor',
'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu', 'rdgy',
'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar', 'spectral',
'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn', 'tealrose',
'tempo', 'temps', 'thermal', 'tropic', 'turbid', 'twilight',
'viridis', 'ylgn', 'ylgnbu', 'ylorbr', 'ylorrd'].
Appending '_r' to a named colorscale reverses it."""
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
highlightcolor="limegreen", project_z=True))
fig.update_layout(title='Bedford Basin Elevation',xaxis_title="Latitude",
yaxis_title="Longitude",autosize=False,
width=900, height=900,
margin=dict(l=65, r=50, b=65, t=90))
fig.update_layout(scene = dict(
xaxis_title='Latitude',
yaxis_title='Longitude',
zaxis_title='Elevation'),
margin=dict(r=20, b=10, l=10, t=10))
# fig.update_layout(color='Elevation')
fig.update_layout(coloraxis_colorbar=dict(
title="Elevation",
thicknessmode="pixels", thickness=50,
lenmode="pixels", len=200,
yanchor="top", y=1,
ticks="outside", ticksuffix="",
dtick=5
))
fig.show()
z_data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import plotly.graph_objects as go
import pandas as pd
import numpy as np
df = pd.read_csv('POINT_DATA_TITLE.csv')
df.head()
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
# from matplotlib.ticker import LinearLocator, FormatStrFormatter
from matplotlib import rc, rcParams
from mpl_toolkits.mplot3d import Axes3D
from scipy.interpolate import griddata
import matplotlib.gridspec as gridspec
# 2D-arrays from DataFrame
x1 = np.linspace(df['x'].min(), df['x'].max(), len(df['x'].unique()))
y1 = np.linspace(df['y'].min(), df['y'].max(), len(df['y'].unique()))
"""
x, y via meshgrid for vectorized evaluation of
2 scalar/vector fields over 2-D grids, given
one-dimensional coordinate arrays x1, x2,..., xn.
"""
x2, y2 = np.meshgrid(x1, y1)
# Interpolate unstructured D-dimensional data.
z2 = griddata((df['x'], df['y']), df['z'], (x2, y2), method='cubic')
# Ready to plot
fig = plt.figure(211,figsize=(15,20))
ax = fig.add_subplot(211, projection='3d')
spec = gridspec.GridSpec(ncols=1, nrows=2,
height_ratios=[4, 1])
surf = ax.plot_surface(x2, y2, z2, rstride=1, cstride=1, cmap=cm.terrain,
linewidth=1, antialiased=False)
ax.view_init(45,-55)
cset = ax.contourf(x2, y2, z2, zdir='z2', offset=-80, cmap=cm.terrain, antialiased=True)
rcParams['legend.fontsize'] = 20
rc('text', usetex=True)
rc('axes', linewidth=2)
rc('font', weight='bold')
rcParams['text.latex.preamble'] = [r'\usepackage{sfmath} \boldmath']
ax.xaxis.set_tick_params(labelsize=20)
ax.yaxis.set_tick_params(labelsize=20)
ax.zaxis.set_tick_params(labelsize=20)
ax.set_zticks([-70, -50, -30, -10, 10, 30, 50, 70, 90, 110])
plt.title(r'\textbf{Bedford Basin Bathymatry}', fontsize=20)
plt.xlabel(r'\textbf{Latitude}', fontsize=20, labelpad= 23)
plt.ylabel(r'\textbf{Longitude}', fontsize=20, labelpad= 20)
ax.set_zlabel(r'\textbf{Elevation}', fontsize=20, labelpad= 10)
fig.savefig('Bedford_BASIN_BATHY_view5.png', dpi=600)
import matplotlib.pyplot as plt
import matplotlib as mpl
fig, ax = plt.subplots(figsize=(15, 1))
# ax = fig.add_subplot(111)
fig.subplots_adjust(bottom=0.5)
cmap = mpl.cm.terrain
norm = mpl.colors.Normalize(vmin=-80, vmax=100)
cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
norm=norm,
orientation='horizontal')
cb1.set_label('Elevation', fontsize=20, weight='bold')
plt.setp(ax.get_xticklabels(), fontsize=20)
fig.savefig('Bedford_BASIN_BATHY_view8.png', dpi=600)
plt.show()
import matplotlib.pyplot as plt
import matplotlib as mpl
left, width = 0.07, 0.65
bottom, height = 0.1, .8
bottom_h = left_h = left+width+0.02
rect_cones = [left, bottom, width, height]
rect_box = [left_h, bottom, 0.05, height]
fig = plt.figure(figsize=(14,7), dpi=300)
cones = plt.axes(rect_cones,projection='3d')
box = plt.axes(rect_box)
cones.plot_surface(x2, y2, z2, rstride=1, cstride=1, cmap=cm.terrain,
linewidth=1, antialiased=False)
cones.set_zlim([-80, 110])
cones.view_init(45,-55)
cset = cones.contourf(x2, y2, z2, zdir='z2', offset=-80, cmap=cm.terrain, antialiased=True)
rcParams['legend.fontsize'] = 20
rc('text', usetex=True)
rc('axes', linewidth=2)
rc('font', weight='bold')
rcParams['text.latex.preamble'] = [r'\usepackage{sfmath} \boldmath']
cones.xaxis.set_tick_params(labelsize=20)
cones.yaxis.set_tick_params(labelsize=20)
cones.zaxis.set_tick_params(labelsize=20)
cones.set_xlabel('Latitude', fontsize=20, labelpad= 23, weight='bold')
cones.set_ylabel('Longitude', fontsize=20, labelpad= 20, weight='bold')
cones.set_zlabel('Elevation', fontsize=20, labelpad= 10, weight='bold')
fig.suptitle('Bedford Basin Bathymatry', fontsize=20, weight='bold')
cmap = mpl.cm.terrain
norm = mpl.colors.Normalize(vmin=-80, vmax=110)
cb1 = mpl.colorbar.ColorbarBase(box, cmap=cmap,
norm=norm,
orientation='vertical', extend='both')
plt.setp(box.get_yticklabels(), fontsize=16);
fig.savefig('Bedford_BASIN_BATHY_Final_fig.png', dpi=600)